#ifndef __AUDIO_PLAYER_HXX__
#define __AUDIO_PLAYER_HXX__

#include "mydll.h"
#include "mytypes.h"
#include "mymutex.hxx"

class FileLog;

class EXPORT AudioPlayer
{
public:
	// \brief Constructor
	//AudioPlayer();

	AudioPlayer(tUInt32 bits_sample,tUInt32 sample_sec,tUInt32 block_nb,tUInt32 block_size,tUInt32 channel_nb,FileLog* filelog=NULL);

	// \brief Destructor
	virtual ~AudioPlayer();

	virtual tInt32 Init() = 0;
	virtual tInt32 UnInit() = 0;

	/**
	 * Write voice data into player, as writed, it plays
	 */
	virtual tInt32 WriteAudio(tByte* data, tUInt32 size) = 0;

	/**
	 * Keep the playing pos at this momment of the call
	 */
	virtual tInt32 SetCurrentPos(void) = 0;

	virtual void ResetCurrentPos(void) = 0;

	virtual tByte* GetLatestData(tInt32 size) = 0;

protected:
	//
	friend class RecordHandler;
	tInt32 IncrFreeBlockCount(void);
	tInt32 DecrFreeBlockCount(void);

	/**
	 * Just Make the player as initialized.It's called by IncrFreeBlockCount
	 * as Template Mode.
	 */
	virtual void	ResetPlayer(void) = 0;

	virtual tByte* AllocateBlocks(tUInt32 count, tUInt32 size) = 0;

	virtual void FreeBlocks(void) = 0;


	/* Configuration for recording */
	
	/* How many bits in a sample */
	tUInt32 _bits_per_sample;

	/* Number of samples picked per second */
	tUInt32 _samples_per_sec;

	/* Number of buffer block for recording */
	tUInt32 _block_nb;

	/* size of each buffer block */
	tUInt32 _block_size;

	tUInt32 _current_block;

	tUInt32 _free_block_count;

	/* always set to 1 or 2 channels */
	tUInt32 _channel_nb;

	tInt32	_current_pos;

	Mutex _mutex_on_count;

	FileLog* _filelog;
};

#endif	// __AUDIO_PLAYER_HXX__